<?php
class Users_model extends CI_Model {
	public function __construct(){
		parent::__construct();
	}
		
	function login($username, $password){
		        // Run the query
        
        $this->db->where('username', $username);
        $this->db->where('password', $password);
        $query = $this->db->get('users');
        // Let's check if there are any results
        if($query->num_rows == 1)
        {
            // If there is a user, then create session data
            $row = $query->row();
            $data = array(
            		'user_id' => $row->id,
                    'username' => $row->username,
                    'password' => $row->password
                    );
            $this->session->set_userdata($data);
            //$this->session->userdata("user_id")
            return true;
        }
        // If the previous process did not validate
        // then return false.
        return false;
	}
	
}